home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / marineb.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  8KB  |  455 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. unsigned char *marineb_column_scroll;
  14. int marineb_active_low_flipscreen;
  15. static int palbank;
  16.  
  17.  
  18. static int flipscreen_x;
  19. static int flipscreen_y;
  20.  
  21.  
  22. WRITE_HANDLER( marineb_palbank0_w )
  23. {
  24.     if ((palbank & 1) != (data & 1))
  25.     {
  26.         palbank = (palbank & ~1) | (data & 1);
  27.         memset(dirtybuffer, 1, videoram_size);
  28.     }
  29. }
  30.  
  31. WRITE_HANDLER( marineb_palbank1_w )
  32. {
  33.     data <<= 1;
  34.     if ((palbank & 2) != (data & 2))
  35.     {
  36.         palbank = (palbank & ~2) | (data & 2);
  37.         memset(dirtybuffer, 1, videoram_size);
  38.     }
  39. }
  40.  
  41. WRITE_HANDLER( marineb_flipscreen_x_w )
  42. {
  43.     if (flipscreen_x != (data ^ marineb_active_low_flipscreen))
  44.     {
  45.         flipscreen_x = data ^ marineb_active_low_flipscreen;
  46.         memset(dirtybuffer, 1, videoram_size);
  47.     }
  48. }
  49.  
  50. WRITE_HANDLER( marineb_flipscreen_y_w )
  51. {
  52.     if (flipscreen_y != (data ^ marineb_active_low_flipscreen))
  53.     {
  54.         flipscreen_y = data ^ marineb_active_low_flipscreen;
  55.         memset(dirtybuffer, 1, videoram_size);
  56.     }
  57. }
  58.  
  59.  
  60. /***************************************************************************
  61.  
  62.   Draw the game screen in the given osd_bitmap.
  63.   Do NOT call osd_update_display() from this function, it will be called by
  64.   the main emulation engine.
  65.  
  66. ***************************************************************************/
  67. static void draw_chars(struct osd_bitmap *_tmpbitmap, struct osd_bitmap *bitmap,
  68.                        int scroll_cols)
  69. {
  70.     int offs;
  71.  
  72.  
  73.     /* for every character in the Video RAM, check if it has been modified */
  74.     /* since last time and update it accordingly. */
  75.     for (offs = videoram_size - 1;offs >= 0;offs--)
  76.     {
  77.         if (dirtybuffer[offs])
  78.         {
  79.             int sx,sy,flipx,flipy;
  80.  
  81.  
  82.             dirtybuffer[offs] = 0;
  83.  
  84.             sx = offs % 32;
  85.             sy = offs / 32;
  86.  
  87.             flipx = colorram[offs] & 0x20;
  88.             flipy = colorram[offs] & 0x10;
  89.  
  90.             if (flipscreen_y)
  91.             {
  92.                 sy = 31 - sy;
  93.                 flipy = !flipy;
  94.             }
  95.  
  96.             if (flipscreen_x)
  97.             {
  98.                 sx = 31 - sx;
  99.                 flipx = !flipx;
  100.             }
  101.  
  102.             drawgfx(_tmpbitmap,Machine->gfx[0],
  103.                     videoram[offs] | ((colorram[offs] & 0xc0) << 2),
  104.                     (colorram[offs] & 0x0f) + 16 * palbank,
  105.                     flipx,flipy,
  106.                     8*sx,8*sy,
  107.                     0,TRANSPARENCY_NONE,0);
  108.         }
  109.     }
  110.  
  111.  
  112.     /* copy the temporary bitmap to the screen */
  113.     {
  114.         int scroll[32];
  115.  
  116.  
  117.         if (flipscreen_y)
  118.         {
  119.             for (offs = 0;offs < 32 - scroll_cols;offs++)
  120.                 scroll[offs] = 0;
  121.  
  122.             for (;offs < 32;offs++)
  123.                 scroll[offs] = marineb_column_scroll[0];
  124.         }
  125.         else
  126.         {
  127.             for (offs = 0;offs < scroll_cols;offs++)
  128.                 scroll[offs] = -marineb_column_scroll[0];
  129.  
  130.             for (;offs < 32;offs++)
  131.                 scroll[offs] = 0;
  132.         }
  133.         copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  134.     }
  135. }
  136.  
  137.  
  138. void marineb_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  139. {
  140.     int offs;
  141.  
  142.  
  143.     draw_chars(tmpbitmap, bitmap, 24);
  144.  
  145.  
  146.     /* draw the sprites */
  147.     for (offs = 0x0f; offs >= 0; offs--)
  148.     {
  149.         int gfx,sx,sy,code,col,flipx,flipy,offs2;
  150.  
  151.  
  152.         if ((offs == 0) || (offs == 2))  continue;  /* no sprites here */
  153.  
  154.  
  155.         if (offs < 8)
  156.         {
  157.             offs2 = 0x0018 + offs;
  158.         }
  159.         else
  160.         {
  161.             offs2 = 0x03d8 - 8 + offs;
  162.         }
  163.  
  164.  
  165.         code  = videoram[offs2];
  166.         sx    = videoram[offs2 + 0x20];
  167.         sy    = colorram[offs2];
  168.         col   = (colorram[offs2 + 0x20] & 0x0f) + 16 * palbank;
  169.         flipx =   code & 0x02;
  170.         flipy = !(code & 0x01);
  171.  
  172.         if (offs < 4)
  173.         {
  174.             /* big sprite */
  175.             gfx = 2;
  176.             code = (code >> 4) | ((code & 0x0c) << 2);
  177.         }
  178.         else
  179.         {
  180.             /* small sprite */
  181.             gfx = 1;
  182.             code >>= 2;
  183.         }
  184.  
  185.         if (!flipscreen_y)
  186.         {
  187.             sy = 256 - Machine->gfx[gfx]->width - sy;
  188.             flipy = !flipy;
  189.         }
  190.  
  191.         if (flipscreen_x)
  192.         {
  193.             sx++;
  194.         }
  195.  
  196.         drawgfx(bitmap,Machine->gfx[gfx],
  197.                 code,
  198.                 col,
  199.                 flipx,flipy,
  200.                 sx,sy,
  201.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  202.     }
  203. }
  204.  
  205.  
  206. void changes_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  207. {
  208.     int offs,sx,sy,code,col,flipx,flipy;
  209.  
  210.  
  211.     draw_chars(tmpbitmap, bitmap, 26);
  212.  
  213.  
  214.     /* draw the small sprites */
  215.     for (offs = 0x05; offs >= 0; offs--)
  216.     {
  217.         int offs2;
  218.  
  219.  
  220.         offs2 = 0x001a + offs;
  221.  
  222.         code  = videoram[offs2];
  223.         sx    = videoram[offs2 + 0x20];
  224.         sy    = colorram[offs2];
  225.         col   = (colorram[offs2 + 0x20] & 0x0f) + 16 * palbank;
  226.         flipx =   code & 0x02;
  227.         flipy = !(code & 0x01);
  228.  
  229.         if (!flipscreen_y)
  230.         {
  231.             sy = 256 - Machine->gfx[1]->width - sy;
  232.             flipy = !flipy;
  233.         }
  234.  
  235.         if (flipscreen_x)
  236.         {
  237.             sx++;
  238.         }
  239.  
  240.         drawgfx(bitmap,Machine->gfx[1],
  241.                 code >> 2,
  242.                 col,
  243.                 flipx,flipy,
  244.                 sx,sy,
  245.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  246.     }
  247.  
  248.     /* draw the big sprite */
  249.  
  250.     code  = videoram[0x3df];
  251.     sx    = videoram[0x3ff];
  252.     sy    = colorram[0x3df];
  253.     col   = colorram[0x3ff];
  254.     flipx =   code & 0x02;
  255.     flipy = !(code & 0x01);
  256.  
  257.     if (!flipscreen_y)
  258.     {
  259.         sy = 256 - Machine->gfx[2]->width - sy;
  260.         flipy = !flipy;
  261.     }
  262.  
  263.     if (flipscreen_x)
  264.     {
  265.         sx++;
  266.     }
  267.  
  268.     code >>= 4;
  269.  
  270.     drawgfx(bitmap,Machine->gfx[2],
  271.             code,
  272.             col,
  273.             flipx,flipy,
  274.             sx,sy,
  275.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  276.  
  277.     /* draw again for wrap around */
  278.  
  279.     drawgfx(bitmap,Machine->gfx[2],
  280.             code,
  281.             col,
  282.             flipx,flipy,
  283.             sx-256,sy,
  284.             &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  285. }
  286.  
  287.  
  288. void springer_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  289. {
  290.     int offs;
  291.  
  292.  
  293.     draw_chars(tmpbitmap, bitmap, 0);
  294.  
  295.  
  296.     /* draw the sprites */
  297.     for (offs = 0x0f; offs >= 0; offs--)
  298.     {
  299.         int gfx,sx,sy,code,col,flipx,flipy,offs2;
  300.  
  301.  
  302.         if ((offs == 0) || (offs == 2))  continue;  /* no sprites here */
  303.  
  304.  
  305.         offs2 = 0x0010 + offs;
  306.  
  307.  
  308.         code  = videoram[offs2];
  309.         sx    = 240 - videoram[offs2 + 0x20];
  310.         sy    = colorram[offs2];
  311.         col   = (colorram[offs2 + 0x20] & 0x0f) + 16 * palbank;
  312.         flipx = !(code & 0x02);
  313.         flipy = !(code & 0x01);
  314.  
  315.         if (offs < 4)
  316.         {
  317.             /* big sprite */
  318.             sx -= 0x10;
  319.             gfx = 2;
  320.             code = (code >> 4) | ((code & 0x0c) << 2);
  321.         }
  322.         else
  323.         {
  324.             /* small sprite */
  325.             gfx = 1;
  326.             code >>= 2;
  327.         }
  328.  
  329.         if (!flipscreen_y)
  330.         {
  331.             sy = 256 - Machine->gfx[gfx]->width - sy;
  332.             flipy = !flipy;
  333.         }
  334.  
  335.         if (!flipscreen_x)
  336.         {
  337.             sx--;
  338.         }
  339.  
  340.         drawgfx(bitmap,Machine->gfx[gfx],
  341.                 code,
  342.                 col,
  343.                 flipx,flipy,
  344.                 sx,sy,
  345.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  346.     }
  347. }
  348.  
  349.  
  350. void hoccer_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  351. {
  352.     int offs;
  353.  
  354.  
  355.     draw_chars(tmpbitmap, bitmap, 0);
  356.  
  357.  
  358.     /* draw the sprites */
  359.     for (offs = 0x07; offs >= 0; offs--)
  360.     {
  361.         int sx,sy,code,col,flipx,flipy,offs2;
  362.  
  363.  
  364.         offs2 = 0x0018 + offs;
  365.  
  366.  
  367.         code  = spriteram[offs2];
  368.         sx    = spriteram[offs2 + 0x20];
  369.         sy    = colorram[offs2];
  370.         col   = colorram[offs2 + 0x20];
  371.         flipx =   code & 0x02;
  372.         flipy = !(code & 0x01);
  373.  
  374.         if (!flipscreen_y)
  375.         {
  376.             sy = 256 - Machine->gfx[1]->width - sy;
  377.             flipy = !flipy;
  378.         }
  379.  
  380.         if (flipscreen_x)
  381.         {
  382.             sx = 256 - Machine->gfx[1]->width - sx;
  383.             flipx = !flipx;
  384.         }
  385.  
  386.         drawgfx(bitmap,Machine->gfx[1],
  387.                 code >> 2,
  388.                 col,
  389.                 flipx,flipy,
  390.                 sx,sy,
  391.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  392.     }
  393. }
  394.  
  395.  
  396. void hopprobo_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  397. {
  398.     int offs;
  399.  
  400.  
  401.     draw_chars(tmpbitmap, bitmap, 0);
  402.  
  403.  
  404.     /* draw the sprites */
  405.     for (offs = 0x0f; offs >= 0; offs--)
  406.     {
  407.         int gfx,sx,sy,code,col,flipx,flipy,offs2;
  408.  
  409.  
  410.         if ((offs == 0) || (offs == 2))  continue;  /* no sprites here */
  411.  
  412.  
  413.         offs2 = 0x0010 + offs;
  414.  
  415.  
  416.         code  = videoram[offs2];
  417.         sx    = videoram[offs2 + 0x20];
  418.         sy    = colorram[offs2];
  419.         col   = (colorram[offs2 + 0x20] & 0x0f) + 16 * palbank;
  420.         flipx =   code & 0x02;
  421.         flipy = !(code & 0x01);
  422.  
  423.         if (offs < 4)
  424.         {
  425.             /* big sprite */
  426.             gfx = 2;
  427.             code = (code >> 4) | ((code & 0x0c) << 2);
  428.         }
  429.         else
  430.         {
  431.             /* small sprite */
  432.             gfx = 1;
  433.             code >>= 2;
  434.         }
  435.  
  436.         if (!flipscreen_y)
  437.         {
  438.             sy = 256 - Machine->gfx[gfx]->width - sy;
  439.             flipy = !flipy;
  440.         }
  441.  
  442.         if (!flipscreen_x)
  443.         {
  444.             sx--;
  445.         }
  446.  
  447.         drawgfx(bitmap,Machine->gfx[gfx],
  448.                 code,
  449.                 col,
  450.                 flipx,flipy,
  451.                 sx,sy,
  452.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  453.     }
  454. }
  455.